package com.atde._01_principle.singleresponsibility;


/**
 * @BelongsProject: hsp_java_design_mode
 * @BelongsPackage: com.atde.principle.singleresponsibility
 * @Author: Del
 * @CreateTime: 2025-04-11  10:59
 * @Description: 单一职责演示 2
 *  TODO 其三个类虽然解决了运行时的单一职责问题 但是还是这样做资源消耗过大 可以改进Vehicle 类，让其变动的代码放在一个类中
 * @Version: 1.0
 */
public class SingleResponsibility02 {
    public static void main(String[] args) {
        RoadVehicle roadVehicle = new RoadVehicle();
        roadVehicle.run("摩托车");
        roadVehicle.run("汽车");

        AirVehicle airVehicle = new AirVehicle();
        airVehicle.run("飞机");

        WaterVehicle waterVehicle = new WaterVehicle();
        waterVehicle.run("轮船");
    }
}

class RoadVehicle {
    public void run(String vehicle){
        System.out.println(vehicle + "公路运行");
    }
}

class AirVehicle {
    public void run(String vehicle){
        System.out.println(vehicle + "天空运行");
    }
}

class WaterVehicle {
    public void run(String vehicle){
        System.out.println(vehicle + "水中运行");
    }
}

